 var id = getvl("id");
 $(function(){
 	   if(id!=''){
 	   	  xiayibu(id);
 	   }else{
 	 // alert("....");
 	   }
 });
  function xiayibu(id){
   	$.ajax({
   	    async:false,
		url: urlcore + "/api/expressPrice/selectChazhao?userId="+id,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
				var  da=data.data;
				 if(da.morenkuaidifei!=null && da.morenkuaidifei!=""){
		$.each(da.morenkuaidifei, function(y,n) {
			 var  morenkuaidifei='<input type="hidden" id="moren" value="'+n.id+'"><li>'+
'			<label>首重(元)</label>'+
'			<input type="text" id="shouchong" value="'+n.firstMoney+'" />'+
'		</li>'+
'		<li>'+
'			<label>续重(元)</label>'+
'			<input type="text" id="xuchong" value="'+n.continuedMoney+'" />'+
'		</li>';	
              $("#morenkuaidifei").append(morenkuaidifei);
				});
				 }else{
	var  morenkuaidifei='<input type="hidden" id="moren" ><li>'+
'			<label>首重(元)</label>'+
'			<input type="text"  id="shouchong"/>'+
'		</li>'+
'		<li>'+
'			<label>续重(元)</label>'+
'			<input type="text" id="xuchong" />'+
'		</li>';	
 $("#morenkuaidifei").append(morenkuaidifei);
				 }
				 if(da.diqukuaidifei!=null){
		$.each(da.diqukuaidifei, function(m,q) {
			   var tedingdiqu=
			  '<div class="sell_yunfei clearfix"><a href="26.1.1xiugaidianpu_yunfei_diqu.html?id='+q.id+'" id="xiugai"><div class="beijing" style="width: 100%; height: 6%;"><center><h5 class="ziti">修改</h5></center></div></a>'+ 			   
	'<div class="public-xuanze fl">'+
	'<img src="../images/delete.png"  onclick="dianjishanchu(this)" id="'+q.id+'" width="20" height="20" />'+
	'</div>'+
			   '<ul class="fl sell_yunfei_add" >'+
			   '<input type="hidden" value="'+q.id+'">'+
			   '<li>'+
            '<label>地区</label>'+
         '<input type="text" readonly="readonly" value="'+q.areaName+'">'+
'</li>'+
'		<li>'+
'			<label>首重</label>'+
'			<input type="text" readonly="readonly" value="'+q.firstMoney+'" />'+
'		</li>'+
'		<li>'+
'			<label>续重</label>'+
'			<input type="text" readonly="readonly" value="'+q.continuedMoney+'" />'+
'		</li>'+
'</ul></div>';
           $("#tedingdiqu").append(tedingdiqu);
		});		
	}
			}
		},
		error:function() {
			/* Act on the event */
			alert("error");
		}
	});	
}
  
  


function dianjishanchu(te){
	  var xiuid=$(te).attr("id");
	    $.ajax({  
        url : urlcore + "/api/expressPrice/update",
        type : "post",  
        contentType: "application/json;charset=utf-8",
        data :JSON.stringify({
        	id:xiuid,
        	status:2
        }),
        	dataType: "json",
        success: function(data) { 
        	location.reload();
        },
        error:function(){  
            alert("保存失败");  
        }  
    });
}




function baochun(){
	 var moren=$("#moren").val();
	 var shoujihao=$("#shouchong").val();
	 var xiangxidizhi=$("#xuchong").html();

           if(moren!="" && moren!=null){
	    $.ajax({  
        url : urlcore + "/api/expressPrice/update",
        type : "post",  
        contentType: "application/json;charset=utf-8",
        data :JSON.stringify({
        	id:moren,
        	firstMoney:shoujihao,
        	continuedMoney:xiangxidizhi,
        }),
        	dataType: "json",
        success: function(data) {//data是返回的hash,key之类的值，key是定义的文件名 
        	//alert("保存成功!");
        	window.location.href = document.referrer
        },
        error:function(){  
            alert("保存失败");  
        }  
    });
      }else{
      	  $.ajax({  
        url : urlcore + "/api/expressPrice/adds",
        type : "post",  
        contentType: "application/json;charset=utf-8",
        data :JSON.stringify({
        	firstMoney:shoujihao,
        	continuedMoney:xiangxidizhi,
        	type:2
        }),
        	dataType: "json",
        success: function(data) {//data是返回的hash,key之类的值，key是定义的文件名 
        	window.location.href = document.referrer
        },
        error:function(){  
            alert("保存失败");  
        }  
    });
      }

}

